﻿using System;
using System.Linq;
using System.IO;
using OpenExcel.OfficeOpenXml;

namespace OpenExcel_Examples
{
    public static class Example5
    {
        public static void Run()
        {
            Console.WriteLine("=== Running Example5 ===");
            string previousFile = Path.Combine(Program.OutputDirectory, "example4.xlsx");
            string outputFile = Path.Combine(Program.OutputDirectory, "example5.xlsx");
            File.Copy(previousFile, outputFile, true);

            DateTime dtStart = DateTime.Now;
            using (ExcelDocument doc = ExcelDocument.Open(outputFile, true))
            {
                ExcelWorksheet wsheet = doc.Workbook.Worksheets.First();
                Program.LogTime(dtStart, "Loaded worksheet");
                wsheet.InsertRows(5, 3);
                Program.LogTime(dtStart, "Inserted rows");
                wsheet.InsertColumns(5, 3);
                Program.LogTime(dtStart, "Inserted columns");
            }
            Program.LogTime(dtStart, "Saved file");
        }
    }
}
